<?php
/**
 * created by zzy
 * date: 2018/5/23 19:41
 */

namespace App\Api\Service\Warehouse\Models;

class OrderWarehouse
{
    public static function changeOrderList($orderList)
    {
        foreach($orderList as $key=>$val)
        {
            //产品图
            $valProductionCaseDiagram   = $val['production_case_diagram'];
            $imgPath                    = '';
            if($valProductionCaseDiagram)
            {
                $imgArr                 = explode(',',$valProductionCaseDiagram);
                $imgId                  = $imgArr[0];
                $imgPath                = Func::getImgUrlById($imgId);
            }
            $orderList[$key]['img_path']    = $imgPath;
            //客户名
            $valCustomerName            = $val['customer_name'];
            $customerName               = \App\Engine\Customer::getNameById($valCustomerName);
            $orderList[$key]['customer_name']   = $customerName;
            //工艺名
            $valOrderType               = $val['order_type'];
            $orderTypeTitle             = \App\Eloquent\Ygt\OrderType::getOneValueById($valOrderType, 'title');
            $orderList[$key]['order_type_title']    = $orderTypeTitle;
            //单位名
            $fieldName23                = \App\Engine\Process::changeFieldName23($val['field_name_23']);
            $orderList[$key]['field_name_23']   = $fieldName23;
            //规格
            $valFinishedSpecification   = $val['finished_specification'];
            $finishedSpecification      = '';
            if ($valFinishedSpecification)
            {
                $finishedSpecification      = str_replace(',', '×', $valFinishedSpecification);
                $finishedSpecification      .= 'cm';
            }
            $orderList[$key]['finished_specification']  = $finishedSpecification;
            //克重
            if(!$val['grammage'])
            {
                $orderList[$key]['grammage']    = '';
            }
        }
        return $orderList;
    }
}
